<template>
	<!-- 课程和消息按钮 -->
	<div class="container">
		<!-- 选项卡导航 -->
		<div class="tab-container">
			<div class="tabs" ref="tabs">
				<div v-for="(tab, index) in tabs" :key="index" :class="['tab-item', { active: activeTab === index }]"
					@click="setActiveTab(index)">
					{{ tab }}
					<div v-if="activeTab === index" class="underline"></div>
				</div>
			</div>
		</div>

		<!-- 右侧图标 -->
		<div class="icon">
			<img src="/static/alibaba_icon/message.svg" alt="chat" />
			<span class="notification-dot"></span>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				tabs: ["精选", "语文", "数学", "英语", "编程", "美术"],
				activeTab: 0
			};
		},
		methods: {
			setActiveTab(index) {
				this.activeTab = index;
				console.log("被点击的选项:", this.tabs[index]);
			}
		}
	};
</script>

<style scoped>
	.container {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 10px 5%;
		background-color: #ffffff;
		position: relative;
	}

	.tab-container {
		flex: 1;
		overflow: hidden;
		display: flex;
		align-items: flex-end;
	}

	.tabs {
		display: flex;
		white-space: nowrap;
		overflow-x: auto;
		scroll-behavior: smooth;
		padding-bottom: 5px;
		margin-right: 10px;
	}

	.tabs::-webkit-scrollbar {
		display: none;
	}

	.tab-item {
		font-size: 16px;
		color: #666;
		padding: 0 15px;
		cursor: pointer;
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.tab-item.active {
		color: #007bff;
		font-weight: bold;
	}

	.underline {
		width: 50%;
		height: 2px;
		background-color: #007bff;
		position: absolute;
		bottom: -3px;
	}

	.icon {
		position: relative;
		width: 24px;
		height: 24px;
		margin-left: 10px;
	}

	.icon img {
		width: 100%;
		height: 100%;
	}

	.notification-dot {
		width: 8px;
		height: 8px;
		background-color: red;
		border-radius: 50%;
		position: absolute;
		top: 0;
		right: 0;
	}
</style>